@import controllers.core.routes.Assets

@(welcome: Html)(implicit session: play.api.mvc.Session)

@exampleName = @{ "movies" }

@projects = @{ org.silkframework.workspace.User().workspace.projects }

@header = {
  <link rel="stylesheet" href="@Assets.at("start.css")" type="text/css" />
}

@toolbar = {
}

@content = {
  <div id="welcome">
    @welcome
  </div>

  <p>
    Your current workspace contains @projects.size project(s).
  </p>

  <button class="mdl-button mdl-js-button mdl-button--raised" onclick="window.location = '@config.baseUrl/workspace'">Open Workspace</button>
  @if(!projects.exists(_.name == exampleName)) {
    <button id="start-load-example" class="mdl-button mdl-js-button mdl-button--raised" onclick="loadExample()" style="margin-left: 5px;">Load Example</button>
  }

  <script type="text/javascript">
    function loadExample() {
      $.post('@config.baseUrl/workspace/@exampleName/importExample')
      .success(function(request) { window.location = '@config.baseUrl/workspace' })
      .fail(function(request) { alert(request.responseText); })
    }
  </script>
}

@main(None, "start")(header)(toolbar)(content)